package com.ttg.common.enums;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonValue;

import java.util.*;

/**
 * 性别（0未知，1男，2女）
 *
 * @author h
 * @date 2023/07/05 14:52:11
 **/
public enum ServiceIdentificationEnum {


    ISSUED_ON_BEHALF_CUSTOM(0, "代发客户"),
    ACQUIRING_MERCHANT(1, "收单商户"),
    PRIORITY_BANKING(2, "理财客户"),
    LOAN_CUSTOMERS(3, "贷款客户"),
    MOBILE_BANKING_CUSTOMERS(4, "手机银行客户"),
    WECHAT_QUICK_PAYMENT(5, "微信快捷支付"),
    ALIPAY_QUICK_PAYMENT(6, "微信快捷支付");


    @JsonValue
    private Integer value;
    private String desc;

    ServiceIdentificationEnum(Integer value, String desc) {
        this.value = value;
        this.desc = desc;
    }

    public Integer getValue() {
        return value;
    }

    public String getDesc() {
        return desc;
    }

    public void setValue(Integer value) {
        this.value = value;
    }

    public void setDesc(String desc) {
        this.desc = desc;
    }

    private static final Map<Integer, ServiceIdentificationEnum> VALUES = new HashMap<>();
    private static final Map<Integer, String> map = new HashMap<>();

    static {
        for (final ServiceIdentificationEnum type : ServiceIdentificationEnum.values()) {
            ServiceIdentificationEnum.VALUES.put(type.getValue(), type);
        }
        for (final ServiceIdentificationEnum type : ServiceIdentificationEnum.values()) {
            ServiceIdentificationEnum.map.put(type.getValue(), type.desc);
        }
    }

    public static List<String> ServiceIdentificationEnum() {
        return new ArrayList<String>(Arrays.asList(
                ServiceIdentificationEnum.ISSUED_ON_BEHALF_CUSTOM.getDesc(),
                ServiceIdentificationEnum.ACQUIRING_MERCHANT.getDesc(),
                ServiceIdentificationEnum.PRIORITY_BANKING.getDesc(),
                ServiceIdentificationEnum.LOAN_CUSTOMERS.getDesc(),
                ServiceIdentificationEnum.MOBILE_BANKING_CUSTOMERS.getDesc(),
                ServiceIdentificationEnum.WECHAT_QUICK_PAYMENT.getDesc(),
                ServiceIdentificationEnum.ALIPAY_QUICK_PAYMENT.getDesc()
        ));
    }
    public static Map<Integer, String> map(){
        return map;
    }


    @JsonCreator
    public static ServiceIdentificationEnum of(Integer code) {
        return ServiceIdentificationEnum.VALUES.get(code);
    }

    @JsonCreator
    public static ServiceIdentificationEnum ofDesc(String desc) {
        for (ServiceIdentificationEnum value : values()) {
            if (value.getDesc().equals(desc)) {
                return value;
            }
        }
        return null;
    }
}
